﻿using Microsoft.EntityFrameworkCore;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

using ZFB.Models;
using ZFB.Models.EntityConfig;

namespace ZFB.Repository.Role
{
    public class RoleRepository : BaseRepository<T_Roles>, IRoleRepository
    {
        private readonly MyDbContext db;
        public RoleRepository(MyDbContext db) : base(db)
        {
            this.db = db;
        }
        public override async Task<T_Roles> GetModelAsync(Expression<Func<T_Roles, bool>> whereExpression)
        {
            return await db.T_Roles
                 .Where(e => !e.IsDeleted)
                 .Include(e => e.T_Permissions)
                 .SingleOrDefaultAsync(whereExpression);
        }
    }
}
